
-- 2012-05-17 EM
alter procedure sp_login
	@phone varchar(21),
	@xml xml output,
	@sid uniqueidentifier output
as
begin
	set nocount on;
	
	exec sp_open_session_by_phone @phone, @xml output, @sid output;
	
	if @sid is null
		exec sp_register @phone, @xml output, @sid output;	
end;
go

grant execute on sp_login to Executer;

/*
USE [dbproc]
GO

DECLARE	@return_value int,
		@xml xml,
		@sid uniqueidentifier

EXEC	@return_value = [dbo].[sp_login]
		@phone = N'79219342929',
		@xml = @xml OUTPUT,
		@sid = @sid OUTPUT

SELECT	@xml as N'@xml',
		@sid as N'@sid'

SELECT	'Return Value' = @return_value

GO
*/